package List_;

import java.util.Objects;

public class Employee implements Comparable {
    private String name;
    private int age;
    private String sex;
    private String post;
    private double salary;
    private String id;

    public Employee() {
    }

    public Employee(String name, int age, String sex, String post, double salary, String id) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.post = post;
        this.salary = salary;
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "员工{" +
                "姓名=" + name + '\'' +
                " 年龄=" + age +
                " 性别=" + sex + '\'' +
                "职务=" + post + '\'' +
                "工资=" + salary +
                '}';
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Employee employee = (Employee) o;
        return age == employee.age &&
                Double.compare(employee.salary, salary) == 0 &&
                Objects.equals(name, employee.name) &&
                Objects.equals(sex, employee.sex) &&
                Objects.equals(post, employee.post) &&
                Objects.equals(id, employee.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, sex, post, salary, id);
    }

    @Override
    public int compareTo(Object o) {
        if (o instanceof Employee) {
            Employee a = (Employee) o;
            return (int) (this.salary - a.salary);
        }
        return 0;
    }
}
